export const TYPES = {
  GET_SUMMARY_REPORT: 'report/getsummaryreport',
  GET_SUMMARY_REPORT_SUCCESS: 'report/getsummaryreportsuccess',
  GET_SUMMARY_REPORT_FAIL: 'report/getsummaryreportfail',
};

const DefaultStore = {
  loading: false,
  summary: {},
  error: {},
};

export default function(store = DefaultStore, action) {
  switch (action.type) {
    case TYPES.GET_SUMMARY_REPORT:
      return {
        ...store,
        loading: true,
        error: {},
      };

    case TYPES.GET_SUMMARY_REPORT_SUCCESS:
      return {
        ...store,
        loading: false,
        summary: action.summary,
        error: {},
      };
    case TYPES.GET_SUMMARY_REPORT_FAIL:
      return {
        ...store,
        loading: false,
        error: {
          type: TYPES.GET_SUMMARY_REPORT_FAIL,
        },
      };

    default:
      return store;
  }
};